package com.example.cqcet_demo.uitls;

import okhttp3.OkHttpClient;

/**
 * Created by Mr.z on 2017/6/17.
 */

public class OkHttpUtil {

    private static OkHttpClient okHttpClient;
    private static OkHttpClient okHttpClientGet;
    private static MyCookieJar myCookieJar =new MyCookieJar();

    public static OkHttpClient getInstance() {
        if (okHttpClient == null)
        okHttpClient = new OkHttpClient.Builder().followRedirects(false)
                .cookieJar(myCookieJar)
                .build();
        return okHttpClient;
    }

    public static OkHttpClient getGetClient(){
        if (okHttpClientGet == null)
            okHttpClientGet = new OkHttpClient.Builder().followRedirects(false)
                    .cookieJar(new MyCookieJar())
                    .build();
        return okHttpClientGet;
    }

    public static void resetCookies(){
        MyCookieJar.resetCookies();
    }
}
